home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Interfaces / CIncludes / UAssociation.h next >
Encoding:
C/C++ Source or Header  |  1990-10-25  |  4.7 KB  |  118 lines  |  [TEXT/MPS ]

  1. /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/
  2. /*UAssociation.p*/
  3. /*Copyright © 1988-1990 by Apple Computer Inc.  All rights reserved*/
  4. #ifndef  __UAssociation__
  5. #define __UAssociation__  0
  6. #endif
  7. #if  ! __UAssociation__
  8. #define __UAssociation__  1
  9.  
  10.         /* • Auto-Include the requirements for this unit's interface */
  11. #ifndef  __UList__
  12. #include "UList.h"
  13. #endif
  14.  
  15. class TEntry : public TObject {
  16.   public:                /* This class has two instances variables to
  17.                                                          store a key string and an associated value
  18.                                                          string*/
  19.  
  20.     StringHandle fKey;                                    /* A handle to the 'keyStr'*/
  21.     StringHandle fValue;                                /* A handle to the 'valueStr'*/
  22.  
  23.     virtual pascal void IEntry(StringPtr itsKey, StringPtr itsValue);
  24.                 /* Initialization routine*/
  25.  
  26.     virtual pascal void Free(void);
  27.                 /* Frees the fKey & fValue string handles then calls inherited free*/
  28.  
  29.     virtual pascal void SetValue(StringPtr value);
  30.                 /* Sets the fValue field to theValue*/
  31.  
  32.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  33.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  34.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  35.                 fields*/
  36.  
  37. };
  38.  
  39. class TEntriesList : public TSortedList {
  40.   public:        /* Subclass of TSortedList that manages a
  41.                                                          sorted list of TEntry objects, used as an
  42.                                                          instance variable in TAssociation*/
  43.  
  44.     virtual pascal void IEntriesList(void);
  45.                 /* Initialize the list */
  46.  
  47.     virtual pascal short Compare(TObject *item1, TObject *item2);
  48.                 /* Compares 'item'1 with 'item2' returning an integer indicating the results of the
  49.                     comparison*/
  50.  
  51.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  52.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  53.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  54.                 fields */
  55.  
  56. };
  57.  
  58. class TAssociation : public TObject {
  59.   public:            /* This class is used to create lists of
  60.                                                          strings that are accessed via their
  61.                                                          associated keys. The keys & strings are
  62.                                                          stored in TEntry objects which are in the
  63.                                                          TEntriesList instance variable*/
  64.  
  65.     TEntriesList *fEntries;                                /* The list of TEntries that stores the
  66.                                                          associations */
  67.  
  68.     virtual pascal void IAssociation(void);
  69.                 /* Initialization routine  */
  70.  
  71.     virtual pascal void Free(void);
  72.                 /* Frees the instance variable fEntries */
  73.  
  74.     virtual pascal Boolean ValueAt(StringPtr keyStr, StringPtr valueStr);
  75.                 /* Given 'keyStr' returns the associated string in 'valueStr', with the result true
  76.                 if an associated string was found */
  77.  
  78.     virtual pascal Boolean KeyAt(StringPtr valueStr, StringPtr keyStr);
  79.                 /* Given 'valueStr' returns the associated key in 'keyStr', with the result true if
  80.                 an associated key was found */
  81.  
  82.     virtual pascal void EachEntryDo(pascal void (*DoToEntry)(TEntry *theEntry, void *
  83.        DoToEntry_StaticLink), void *DoToEntry_StaticLink);
  84.                 /* Iterates over each entry passing it to "DoToEntry" */
  85.  
  86.     virtual pascal TEntry *EntryWithKey(StringPtr keyStr);
  87.                 /* Returns the Entry containing 'keyStr' */
  88.  
  89.     virtual pascal TEntry *EntryWithValue(StringPtr valueStr);
  90.                 /* Returns the entry containing 'valueStr' */
  91.  
  92.     virtual pascal TEntry *FirstEntryThat(pascal Boolean (*TestEntry)(TEntry *theEntry, void *
  93.        TestEntry_StaticLink), void *TestEntry_StaticLink);
  94.  
  95.         /* Iterates over each entry passing it to "TestEntry" until the result of the Test is
  96.                 TRUE */
  97.  
  98.     virtual pascal void InsertEntry(StringPtr keyStr, StringPtr valueStr);
  99.                 /* Inserts an entry into thei association, if 'keyStr' already exists then the value
  100.                 is merely replaced with 'valueStr'. Otherwise a new Entry is created with the above
  101.                 'keyStr' and 'valueStr' */
  102.  
  103.     virtual pascal void RemoveValueAt(StringPtr keyStr);
  104.                 /* Removes the value associated with 'keyStr' */
  105.  
  106.     virtual pascal void RemoveKeyAt(StringPtr valueStr);
  107.                 /* Removes the key associated with 'valueStr' */
  108.  
  109.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  110.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  111.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  112.                 fields */
  113.  
  114. };
  115.  
  116. #endif
  117.  
  118.